home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / zbpc_460.zip / UTILITY.EXE / CALL1.BAS < prev    next >
BASIC Source File  |  1990-06-16  |  2KB  |  39 lines

  1. 00010 ' This program demonstrates a method by which BASICA's CALL statement
  2. 00020 ' can be emulated (with parameter passing)
  3. 00030 :
  4. 00040 DIM Offset%,Segment% : ' Segment% MUST come directly after Offset%
  5. 00050 :
  6. 00060 LONG FN Call_A(Offset%,Segment%,PARM1%,PARM2%,DEST%) : 'etc...
  7. 00070   ' Each parameter must be pushed on the stack
  8. 00080   MACHLG &B8, PARM1%       : ' MOV  AX,PARM1%
  9. 00090   MACHLG &50               : ' PUSH AX
  10. 00100   MACHLG &B8, PARM2%       : ' MOV  AX,PARM2%
  11. 00110   MACHLG &50               : ' PUSH AX
  12. 00120   MACHLG &8B, &06, DEST%   : ' MOV  AX,[DEST%]
  13. 00130   MACHLG &50               : ' PUSH AX
  14. 00140   ' And then a FAR CALL must be performed to the subroutine
  15. 00150   MACHLG &FF, &1E, Offset% : ' CALL [Offset%]  ; intersegment call
  16. 00160 END FN
  17. 00170 :
  18. 00180 ' First, get the two numbers to add
  19. 00190 INPUT "Enter two integers to add together (A%,B%) -> "; A%, B%
  20. 00200 ' And then call the LONG FN to perform the actual CALL
  21. 00210 FN Call_A(LINE 290, MEMC, A%, B%, VARPTR(C%)) : ' Add 'em together
  22. 00220 PRINT C% : ' Print the stored result
  23. 00230 END
  24. 00240 :
  25. 00250 ' This machine language subroutine simply adds two variables and stores
  26. 00260 ' the result in a third.  Addresses for all three variables are passed
  27. 00270 ' on the stack.
  28. 00280 :
  29. 00290 MACHLG &55         : ' PUSH BP          ; Save BP
  30. 00300 MACHLG &89, &E5    : ' MOV  BP,SP       ; Get frame pointer
  31. 00310 MACHLG &8B,&76,&0A : ' MOV  SI,[BP+10]  ; Get address of first parm
  32. 00320 MACHLG &8B,&04     : ' MOV  AX,[SI]     ; Get value of first parm
  33. 00330 MACHLG &8B,&76,&08 : ' MOV  SI,[BP+8]   ; Get address of parm 2
  34. 00340 MACHLG &03,&04     : ' ADD  AX,[SI]     ; Add value to parm 1
  35. 00350 MACHLG &8B,&7E,&06 : ' MOV  DI,[BP+6]   ; Get address for result
  36. 00360 MACHLG &89,&05     : ' MOV  [DI],AX     ; Store result of addition
  37. 00370 MACHLG &5D         : ' POP  BP          ; Restore BP
  38. 00380 MACHLG &CA,&06,&00 : ' RETF 6           ; Far return, pop parms from stack
  39.